package com.uenpay.oem.util;

import android.text.TextUtils;

import com.uenpay.oem.R;

/**
 * Author: liulou Date: 2017/6/27. desc: 银行卡相关操作工具类
 */

public class BankCardUtil {

    /**
     * 获取银行卡后四位
     *
     * @param cardNum 银行卡号
     * @return 后四位数字
     */
    public static String getLast4NumOfBankCard(String cardNum) {
        if (TextUtils.isEmpty(cardNum) || cardNum.length() < 4)
            return null;
        return cardNum.substring(cardNum.length() - 4);
    }

    /**
     * 通过银行的名字获取银行对应的logo图片
     *
     * @param name
     * @return
     */
    public static int getLogoByBankName(String name) {
        int logoRes = -1;
        switch (name) {
            case "招商银行":
                logoRes = R.drawable.icon_bank_zhaoshang;
                break;
            case "中国银行":
                logoRes = R.drawable.icon_bank_china;
                break;
            case "中信银行":
                logoRes = R.drawable.icon_bank_zhongxin;
                break;
            case "浦发银行":
                logoRes = R.drawable.icon_bank_pufa;
                break;
            case "建设银行":
                logoRes = R.drawable.icon_bank_jianshe;
                break;
            case "工商银行":
                logoRes = R.drawable.icon_bank_gongshang;
                break;
            case "交通银行":
                logoRes = R.drawable.icon_bank_jiaotong;
                break;
            case "民生银行":
                logoRes = R.drawable.icon_bank_minsheng;
                break;
            case "农业银行":
                logoRes = R.drawable.icon_bank_nongye;
                break;
            case "邮政储蓄银行":
                logoRes = R.drawable.icon_bank_youzheng;
                break;
            case "华夏银行":
                logoRes = R.drawable.icon_bank_huaxia;
                break;
            case "北京银行":
                logoRes = R.drawable.icon_bank_beij;
                break;
            case "广发银行":
                logoRes = R.drawable.icon_bank_guangfa;
                break;
            case "平安银行":
                logoRes = R.drawable.icon_bank_pingan;
                break;
            case "上海银行":
                logoRes = R.drawable.icon_bank_shanghai;
                break;
            case "兴业银行":
                logoRes = R.drawable.icon_bank_xinye;
                break;
            case "花旗银行":
                logoRes = R.drawable.icon_bank_huaqi;
                break;
            case "渣打银行":
                logoRes = R.drawable.icon_bank_zhada;
                break;
            case "发展银行":
                logoRes = R.drawable.icon_bank_fazhan;
                break;
            case "广大银行":
                logoRes = R.drawable.icon_bank_guangda;
                break;
            case "中国平安":
                logoRes = R.drawable.icon_bank_zhongguopan;
                break;
            case "上海农商银行":
                logoRes = R.drawable.icon_bank_shnongshang;
                break;
            default:
                logoRes = R.drawable.ic_launcher;
                break;
        }
        return logoRes;
    }

    /**
     * 通过银行的名字获取银行对应的logo 小图片
     *
     * @param name
     * @return
     */
    public static int getSmallLogoByBankName(String name) {
        int logoRes = -1;
        switch (name) {
            case "招商银行":
                logoRes = R.drawable.icon_bank_zhaoshang_small;
                break;
            case "中国银行":
                logoRes = R.drawable.icon_bank_china_small;
                break;
            case "中信银行":
                logoRes = R.drawable.icon_bank_zhongxin_small;
                break;
            case "浦发银行":
                logoRes = R.drawable.icon_bank_pufa_small;
                break;
            case "建设银行":
                logoRes = R.drawable.icon_bank_jianshe_small;
                break;
            case "工商银行":
                logoRes = R.drawable.icon_bank_gongshang_small;
                break;
            case "交通银行":
                logoRes = R.drawable.icon_bank_jiaotong_small;
                break;
            case "民生银行":
                logoRes = R.drawable.icon_bank_minsheng_small;
                break;
            case "农业银行":
                logoRes = R.drawable.icon_bank_nongye_small;
                break;
            case "邮政储蓄银行":
                logoRes = R.drawable.icon_bank_youzheng_small;
                break;
            case "华夏银行":
                logoRes = R.drawable.icon_bank_huaxia_small;
                break;
            case "北京银行":
                logoRes = R.drawable.icon_bank_beij_small;
                break;
            case "广发银行":
                logoRes = R.drawable.icon_bank_guangfa_small;
                break;
            case "平安银行":
                logoRes = R.drawable.icon_bank_pingan_small;
                break;
            case "上海银行":
                logoRes = R.drawable.icon_bank_shanghai_small;
                break;
            case "兴业银行":
                logoRes = R.drawable.icon_bank_xinye_small;
                break;
            case "花旗银行":
                logoRes = R.drawable.icon_bank_huaqi_small;
                break;
            case "渣打银行":
                logoRes = R.drawable.icon_bank_zhada_small;
                break;
            case "发展银行":
                logoRes = R.drawable.icon_bank_fazhan_small;
                break;
            case "光大银行":
                logoRes = R.drawable.icon_bank_guangda_small;
                break;
            case "中国平安":
                logoRes = R.drawable.icon_bank_zhongguopan_small;
                break;
            case "上海农商银行":
                logoRes = R.drawable.icon_bank_shnongshang_small;
                break;
            default:
                logoRes = R.drawable.ic_launcher;
                break;
        }
        return logoRes;
    }

    /**
     * 转换银行卡类型
     *
     * @param type 1 为储蓄卡 否则为信用卡
     * @return
     */
    public static String getBankCardType(String type) {
        if ("1".equals(type)) {
            return "储蓄卡";
        } else {
            return "信用卡";
        }
    }
}
